<template>
	<!-- 添加弹框 -->
		<el-dialog  width="55%" title=""   visible :show-close="false" :append-to-body="true" class="wrap" @close="cancel" :close-on-click-modal="false">
		<i class="el-icon-close close" @click="cancel" style="color: white;"></i>
	    <div class="bt">计划资料互动计划编辑</div>
		<el-form label-width="100px"  class="form">
      <el-form-item label="计划名称" class="select-block">
        <input type="text" v-model="form.mc" style="width:90%" >
      </el-form-item>
      <el-form-item label="计划类型" class="select-block">
        <div class="dx">
          <el-radio-group v-model="radio2">
            <el-radio :label="1">微信计划</el-radio>
            <el-radio :label="2">短信计划</el-radio>
            <el-radio :label="3">电话计划</el-radio>
            <el-radio :label="4">下线沟通</el-radio>
          </el-radio-group>
        </div>
      </el-form-item>
      <el-form-item label="计划内容" style="margin-bottom:10px;" class="select-block">
      </el-form-item>
      <div class="jhnr">
        <div class="jhnrfl">
          <el-radio-group v-model="radio1" style="margin-left:30px; margin-top:15px;">
            <el-radio :label="1">文本内容</el-radio>
            <el-radio :label="2">活动资源</el-radio>
          </el-radio-group>
          <el-input type="textarea" v-model="form.nr" :rows="6" style="margin-top:10px;"></el-input>
        </div>
      </div>
      <span style="margin-left:5%;">重要提示信息（话术、营销要点）</span>
      <div class="jhnr">
          <el-input type="textarea" v-model="form.jhnr" :rows="6" style="margin-top:10px;"></el-input>
      </div>
			<el-button type="primary" class="submit" @click="submit">保存</el-button>
		</el-form>
		<!-- </el-dialog> -->
	</el-dialog>
</template>
<script type="text/javascript">
	import qs from 'qs'
	export default {
		props: ['params'],
		data() {
			return {
				form :{
					mc:'',
					jhnr:'',
				},
				radio2:1,
				radio1:1,
			}
		},
		created() {
			console.log(this.params)
			this.gtjhid = this.params
			this.loadinfo()
		},
		methods: {
			loadinfo(){
				 var logininfo = JSON.parse(localStorage.logininfo);
				 var params3 = qs.stringify({
							 xxid:logininfo.xxid,
							 yhid:logininfo.id,
							 gtjhid:this.gtjhid
						});
				 this.axios.post(this.$store.state.api+'gtjh/info',params3)
				 .then( res =>  {
					 console.log(res,'123r32')
					 this.form = res.data.data
					 this.radio2 = parseInt(res.data.data.lx)
					 }).catch(res => {
						 this.$message.warning("服务器异常");
							this.$emit('close', { type: 'info', cancel: true });
					 })
			},
			getjslist(){
				var logininfo = JSON.parse(localStorage.logininfo);
              this.searchLoading = true;
             var params2 = qs.stringify({
                     xxid:logininfo.xxid,
               })
             //执行
                 this.axios.post(this.$store.state.api + 'xxjs/mc',  params2 )
                 .then(res => {
                 console.log(1)
							console.log(res)
							let data = res.data.data;
							this.jsboxlist = data;
                 }).catch(res => {
				})
			},



			submit() {
				this.$store.state.loading = true;
				var logininfo = JSON.parse(localStorage.logininfo);
				var params3 = qs.stringify({
					mc:this.form.mc,
					lx:this.radio2,
					nr:this.form.nr,
					gtjhid:this.gtjhid
				});
				//执行
				this.axios.post(this.$store.state.api + 'gtjh/update', params3)
					.then(res => {
						if(res.data.code == 1) {
							this.$emit('close', { type: 'edit', cancel: false });
							this.$store.state.loading = false;
						} else {
							this.$emit('close', { type: 'edit', cancel: false });
							this.$store.state.loading = false;
						}
					}).catch(res => {
						this.$message.warning("服务器繁忙，请重试");
						//this.$emit('close', { type: 'add', cancel: false });
						this.$store.state.loading = false;
					})
			},




			cancel() {
				this.$emit('close', { type: 'edit', cancel: true })
			},
			componentsShow (type,data) { //显示组件
								console.log(type,data)
								for ( let i in this.portComponents ) {
										if (type == this.portComponents[i].type) {
												this.portComponents[i].toggle = true;
												this.portComponents[i].params = data;
												if (this.portComponents[i].data.type == 'single') {
														this.portComponents[i].data.index = data.row.id
												}else if(this.portComponents[i].data.type == 'multiple'){
														this.portComponents[i].data.index = this.multipleDelNum;
												}else{
														return;
												}
												return;
										}
								}
						},
						componentsHide (setting) { //关闭组件
								for ( let i in this.portComponents ) {
										if (setting.type == this.portComponents[i].type) {
											 this.portComponents[i].toggle = false;
											 if (this.portComponents[i].type=='bq'){
													if (!setting.cancel) {
														 for ( let b in setting.clist ) {

													}

													}
											 }else{
												if (!setting.cancel) {
												}
											 }
											 return;
										}
								}
						}
		}
	}
</script>
<style lang="less" scoped >
	.wrap {
    .select-block{
      .dx{
        width: 90%;
        height: 30px;
        border-bottom:  1px solid #ccc;
      }
    }
    input {
        border:none;
        outline: none;
        background: transparent;
        border-bottom:1px solid #ccc;
    }
    .jhnr{
      width: 85%;
      margin-left: 5%;
      height: 200px;
      .jhnrfl{
        width: 100%;
        height: 40px;
        border: 1px solid #ccc;
        border-radius: 5px;
      }
    }
		.bt{
			position: absolute;
			width: 100%;
			height: 50px;
			margin: 0 auto;
			top: 0;
			left: 0;
			// margin-top: -70px;
			background: #50BFFF;
			// margin-left: -20px;
			// margin-bottom: 20px;
			color:white;
			text-align:left;
			line-height: 50px;
			font-size: 17px;
			padding-left: 15px;
		}
		.close{
				z-index: 10;
				position: absolute;
		}


		.submit {
			width: 120px;
			display: block;
			// float: left;
			margin: 0 auto;
			margin-top: 20px;
		}


		.form {
			text-align: left;
			margin-top: 20px;
			.xx{
				width: 100%;
				height: 100px;
				border: 1px solid #000;
				overflow: hidden;
				.mc{
					width: 20%;
					height: 100px;
					border: 1px solid #000;
					float: left;
				}
				.bq{
					width: 80%;
					height: 100px;
					border: 1px solid #000;
					float: left;
				}
			}
			.jh{
				.fz{
					margin-top: 20px;
					overflow: hidden;
					.left{
						width: 75%;
						float: left;
					}
					.right{
						float: left;
						margin-left: 20px;
					}
					span{

						font-size: 25px;
						width: 40px;
						height: 40px;
						// border: 1px solid #DFE4ED;
						// border-radius: 5px;
						cursor:pointer;
						text-align: center;
						line-height: 40px;
					}
				}
				.list{
					width: 100%;
					border: 2px solid #e8e8e8;
					padding-bottom: 30px;
					li{
						height: 80px;
						width: 90%;
						border: 2px solid #DFE4ED;
						margin: 0 auto;
						margin-top: 20px;
					}
				}
			}
		}


	}

</style>
